home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / ObjInt.C < prev    next >
C/C++ Source or Header  |  1992-04-27  |  703b  |  46 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "ObjInt.h"
  6.  
  7. #include "Class.h"
  8. #include "String.h"
  9.  
  10. NewMetaImpl(ObjInt,Object, (T(val)));
  11.  
  12. //---- an integer object -------------------------------------------------------
  13.  
  14. unsigned long ObjInt::Hash()
  15. {
  16.     return (u_long) val;
  17. }
  18.  
  19. bool ObjInt::IsEqual(Object* op)
  20. {
  21.     return op->IsKindOf(ObjInt) && val == ((ObjInt*)op)->val;
  22. }
  23.  
  24. int ObjInt::Compare(Object* op)
  25. {
  26.     return val - Guard(op, ObjInt)->val;
  27. }
  28.  
  29. char* ObjInt::AsString()
  30. {
  31.     return form("%d", val);
  32. }
  33.  
  34. OStream& ObjInt::PrintOn(OStream &s)
  35. {
  36.     Object::PrintOn(s);
  37.     return s << val SP;
  38. }
  39.  
  40. IStream& ObjInt::ReadFrom(IStream &s)
  41. {
  42.     Object::ReadFrom(s);
  43.     return s >> val;
  44. }
  45.  
  46.